<?php
Yii::import('bootstrap.widgets.TbMenu', true);

class ProjectListWidget extends TbMenu
{
	public $type = TbMenu::TYPE_LIST;
	public $htmlOptions = array('class' => 'bs-docs-sidenav affix');
	public $stacked = true;

	public function init()
	{
		$items = array();
		$items[] = array(
			'label' => '项目列表',
			'icon' => 'th-list',
			'url' => array('project/index'),
		);
		$user = Yii::app()->user->getModel(); /* @var $user User */
		foreach (Yii::app()->pf->getAll() as $tmp) {
			if (isset($tmp['error']) || !$user->hasAccess($tmp['name'])) {
				continue;
			}
			$items[] = array(
				'label' => $tmp['name'],
				'icon' => 'plus-sign',
				'url' => array('project/schema', 'project' => $tmp['name']),
			);
		}
		$this->items = $items;
		parent::init();
	}
}
